/**
 * @author: 小佘佘🦀
 * @description: 上传Excel文件
 * @param {Blob} file
 * @param {number} id
 * 
 * */

import { resetState } from "@/lib/store";
import toast from "react-hot-toast";



export const uploadFileExcel = async (file: Blob, id: number) => {

    const formData = new FormData();
    formData.append('file', file);
    formData.append('id', id + "");


    const response = await fetch(`/api-backend/api/team/upload`, {
        method: "post",
        mode: "no-cors",
        body: formData,
        redirect: "manual"
    })

    if (!response.ok) {
        toast.dismiss()
        toast.error("未授权请重新登录")
        resetState()
        return false
    }

    // 返回标志
    return response
}